package com.witsight.platform.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.witsight.platform.dao.CommonRepository;
import com.witsight.platform.model.BoEntity;
import com.witsight.platform.service.CommonService;

/**   
 * 说明：共通服务抽象类
 * @Title: CommonServiceImpl.java 
 * @Package com.witsight.platform.service.impl 
 * @See: {@link #CommonServiceImpl(CommonRepository)}
 * Copyright: Copyright (c) 2017
 * Company:sany huax witsight team by product
 * @author: penght  
 * @date: 2017年10月9日 上午8:23:33 
 * @version: V1.0
 *
 */
public abstract class CommonServiceImpl implements CommonService {
	/**
	 * Log variable for all child classes. Uses LogFactory.getLog(getClass()) from Commons Logging
	 */
	protected final Logger log = LoggerFactory.getLogger(this.getClass());
	
	// 自定义的动态Sq实现 ,共通Dao
	private CommonRepository commonRepository;
	
	protected CommonServiceImpl(CommonRepository commonRepository) {
		this.commonRepository = commonRepository;
	}
	
	@Override
	public <O> List<O> findSqlAllByParams(String queryName, BoEntity params) {
		return commonRepository.findSqlAllByParams(queryName, params);
	}

	@Override
	public <O> O findSqlOneByParams(String queryName, BoEntity params) {
		return commonRepository.findSqlOneByParams(queryName, params);
	}

	@Override
	public <O> Page<O> findSqlPageByParams(String queryName, BoEntity params, Pageable pageable) {
		return commonRepository.findSqlPageByParams(queryName, params, pageable);
	}
}
